import 'package:flutter/material.dart';
import 'package:test_flutter/common/style/common_style.dart';

class TabNavPage extends StatefulWidget {
  @override
  _TabNavPageState createState() {
    return _TabNavPageState();
  }
}

class _TabNavPageState extends State<TabNavPage> {
  @override
  Widget build(BuildContext context) {
    // return _NestedScrollView();
    return _CustomScrollView();
  }

  _CustomScrollView() {
    return CustomScrollView(slivers: [
      SliverAppBar(),
    ]);
  }

  // ignore: non_constant_identifier_names
  _NestedScrollView() {
    return NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              title: Text('黄磊'),
              expandedHeight: 220,
              pinned: true,
              flexibleSpace: FlexibleSpaceBar(
                title: Container(
                  width: double.infinity,
                  height: 80,
                  child: Text('张子枫'),
                ),
                background: Image.network(
                    "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3973205516,2763305409&fm=26&gp=0.jpg"),
              ),
            )
          ];
        },
        body: ListView.builder(
          itemBuilder: (BuildContext context, int index) {
            return Container(
              height: 80,
              alignment: Alignment.center,
              color: Colors.primaries[index % Colors.primaries.length],
              child: Text(
                '$index',
                style: TextStyle(
                    color: UIColors.common_color_white,
                    decoration: TextDecoration.none),
              ),
            );
          },
          itemCount: 20,
        ));
  }
}
